package com.lj.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lj.mapper.ClientProjectljMapper;
import com.lj.pojo.ClientProjectljExample;
import com.lj.pojo.ClientProjectljKey;
import com.lj.pojo.Clientlj;
import com.lj.pojo.ClientljExample;
import com.lj.service.ClientProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClientProjectServiceImpl implements ClientProjectService {
    @Autowired
    ClientProjectljMapper clientProjectljMapper;
    @Override
    public PageInfo selectClientProject(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        ClientProjectljExample example=new ClientProjectljExample();
        example.setOrderByClause("client_id desc");
        List<ClientProjectljKey> list=clientProjectljMapper.selectByExample(example);
        PageInfo<ClientProjectljKey> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int insertClientProject(ClientProjectljKey clientProjectljKey) {
        return clientProjectljMapper.insert(clientProjectljKey);
    }

    @Override
    public int delete(ClientProjectljKey clientProjectljKey) {
        return clientProjectljMapper.deleteByPrimaryKey(clientProjectljKey);
    }

    @Override
    public ClientProjectljKey getById(String id) {
        ClientProjectljExample example=new ClientProjectljExample();
        example.createCriteria().andClientIdEqualTo(id);
            return clientProjectljMapper.selectByExample(example).get(0);
    }

    @Override
    public int update(ClientProjectljKey clientProjectljKey) {
        ClientProjectljExample example=new ClientProjectljExample();
        example.createCriteria().andClientIdEqualTo(clientProjectljKey.getClientId());
        return clientProjectljMapper.updateByExample(clientProjectljKey,example);
    }
}
